This repository was archived by the owner on Apr 26, 2026. It is now read-only.
Add image support in user messages#13
Open
Aptul9 wants to merge 1 commit into
Open
Conversation
Convert AI SDK v6 file/image parts into the Anthropic image content
block format expected by the Claude CLI on stream-json input. Accepts
base64 data URIs (the format OpenCode stores on disk), raw base64
strings with mediaType/mime/mimeType, and Uint8Array buffers. Remote
URLs and unsupported media types are skipped with a warning.
Requires the model config in opencode.json to declare
"modalities": { "input": ["text", "image"], "output": ["text"] }
and "attachment": true, otherwise OpenCode filters file parts before
they reach the plugin.
Also ignore the local context.md scratchpad.
Closed
9 tasks
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Convert AI SDK v6
file/imageparts into the Anthropicimagecontent block ({ type: "image", source: { type: "base64", media_type, data } }) expected by the Claude CLI on stream-json input. Without this change the plugin silently drops attachments and the model replies as if vision were unsupported.Behavior
Accepts:
data:image/png;base64,...) — the format OpenCode stores on diskmediaType/mime/mimeTypeUint8ArraybuffersRejects with a warning (returns null, part is skipped):
http(s)://URLs — Claude API only accepts inline base64image/png,image/jpeg,image/gif,image/webpsource.dataConfig requirements
Models that should accept images must declare both in
opencode.json:{ "attachment": true, "modalities": { "input": ["text", "image"], "output": ["text"] } }Without
modalities.inputincludingimage, OpenCode filters file parts before they reach the plugin and replaces them with a[Image #N]text placeholder.Test plan
modalitiesset): image attached, Sonnet 4.6 and Opus 4.7 describe content correctlyUint8Array,http(s)URL (rejected), unsupported media type (rejected), missing data (rejected)Split from a previous combined PR per maintainer request. Depends on nothing; builds on top of current
master.